package com.jekun.helloworld;

import org.junit.Test;

import java.util.ArrayList;
import java.util.List;

/**
 * @Author Joey
 * @Date 2022/10/27 20:56
 * @Description
 */
public class Interview {

    @Test
    public void test() {
        //分别会输出什么
        Integer i1 = 127;
        Integer i2 = 127;
        System.out.println(i1 == i2);

        Integer i3 = 130;
        Integer i4 = 130;
        System.out.println(i3 == i4);

        Integer i9 = new Integer("127");
        Integer i10 = new Integer("127");
        System.out.println(i9 == i10);
    }

    @Test
    public void list() {
//        代码会报错么
        String removeName = "李明";

        List<String> list = new ArrayList<String>();
        list.add("张三");
        list.add("李四");
        list.add("王五");
        list.add("李明");

//        for (int i = 0; i < list.size(); i++) {
//            if (list.get(i).equals(removeName)) {
//                list.remove(i);
//            }
//        }

        for (String name : list) {
            if (removeName.equals(name)) {
                list.remove(name);
            }
        }

//        list.removeIf(removeName::equals);
        System.out.println(list);
    }
}
